package com.ktjy.controller;

import com.ktjy.service.ITransferService;
import com.ktjy.utils.AjaxResult;
import com.ktjy.vo.TransferVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Slf4j
@Tag(name="转派管理")
@RestController
@RequestMapping("/tb/transfer")
public class TransferController {
    @Autowired
	ITransferService transferService;

	@Operation(summary = "转派列表查询")
    @GetMapping("/list")
	public AjaxResult list(){
		List<TransferVo> list = transferService.findList();
		return AjaxResult.success(list);
	}
	@Operation(summary = "转派处理")
	@PutMapping("/assign/{type}/{userId}/{transferUserId}")
	public AjaxResult assign(@PathVariable("type") String type,
							 @PathVariable("userId") Long userId,
							 @PathVariable("transferUserId") Long transferUserId) {
		try {
			Map<String, Object> map = transferService.assign(type, userId, transferUserId);
			return AjaxResult.success(map);
		} catch (Exception e) {
			log.error("TransferController中assign方法执行报错的。",e);
		}
		return AjaxResult.error();
	}
}
